﻿/*
 *
 * @author
 * @version
 */
 class com.mixmedia.utils.MakeCheckDigit {
	public function MakeCheckDigit(){
	}
	
	static function makeSSN(s):String{//s is 12 digit number, 7th must 1|2
		if(s.length!=12){
			trace("length not match");
		}
		if( s.charAt(6) == "1" || s.charAt(6)== "2" ){
			var checkDigit = (( 11 - ((Number(s.charAt(0))*2+Number(s.charAt(1))*3+Number(s.charAt(2))*4+Number(s.charAt(3))*5+Number(s.charAt(4))*6+Number(s.charAt(5))*7+Number(s.charAt(6))*8+Number(s.charAt(7))*9+Number(s.charAt(8))*2+Number(s.charAt(9))*3+Number(s.charAt(10))*4+Number(s.charAt(11))*5)% 11)))%10;
			return(s+checkDigit);
		}else{
			trace("wrong");
		}
	}
	
	public function encTime(ms){
		var timeLeft = String(ms);
		while(timeLeft.length<6){
			timeLeft = "0"+timeLeft;//fill zero
		}
		//random number
		timeLeft += "1";
		for(var i=0;i<5;i++){//
			timeLeft += String(random(9));
		}
	}
}